<?php $this->load->view('layout/header'); ?>
<?php js('gongying','tourism')?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">商品管理</a></li>
            <li class="active"><a href="<?php echo site_url('tourismprovidercategory/edit/'.$category->id);?>">编辑商品类别</a></li>
        </ul>
        <?php echo execute_alert_message();?>
        <div class="product-alls">
            <div class="product-fonter">编辑商品类别</div>
            <form class="form-horizontal" action="<?php echo site_url('tourismprovidercategory/editPost/'.$category->id);?>" method="post" id="tourismprovider_add">
                <div class="form-group">
                    <label class="col-sm-1 control-label">类别名称</label>
                    <div class="col-xs-6">
                         <input type="text" class="form-control required" name="category_name" placeholder="类别名称" value="<?php echo isset($category->category_name) ? $category->category_name : '';?>" />
                         <input type="hidden" name="id" value="<?php echo isset($category->id) ? $category->id :'' ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">排序</label>
                    <div class="col-xs-6">
                         <input type="text" class="form-control required number" name="sort" placeholder="排序，越大越前" value="<?php echo isset($category->sort) ? $category->sort : '';?>"/>
                    </div>
                </div>
                <div class="form-btn">
                    <a href="javascript:;">
                        <button class="btn btn-info" >保存</button>
                    </a>
                    <a href="<?php echo site_url('tourismprovidercategory/grid');?>">返回上一步</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
$('.form-btn').on('click','a',function(event){
    $('form#tourismprovider_add').validate({
    	rules:{
          	 category_name : {
                   remote:{
                      url  : hostUrl()+'/tourismprovidercategory/checkNameRepeat',
                      type : 'get',
                      dataType : 'json',
                      data : {
                      	     category_name : function(){return $('input[name="category_name"]').val();},
                             id            : function(){return $('input[name="id"]').val();}
                             } 
                   }
              }
        },
        messages:{
          	category_name :{ remote:'该分类已经存在'}
        },
        submitHandler:function(form) {
            form.submit();
        }
    });
    event.stopPropagation();
})
</script>
<?php $this->load->view('layout/footer'); ?>
